package com.ims.repository;

import com.ims.entity.StipendEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface StipendRepository extends JpaRepository<StipendEntity,Integer>{
    @Query("select st.time from StipendEntity st join st.student s " +
            "where s.major like ?1 and s.stuClass like ?2 " +
            "group by st.time")
    List<String> getTimeOptions(String major,String stu_class);


    @Query("select st.level from StipendEntity st join st.student s " +
            "where s.major like ?1 and s.stuClass like ?2 group by st.level")
    List<String> getLevelOptions(String major,String stu_class);


    // 此处查询出记录若同一人有多条且都符合条件则都会输出
    @Query("select st from StipendEntity st join st.student s " +
            "where s.major like ?1 and s.stuClass like ?2 " +
            "and st.time like ?3 and st.level like ?4 ")
    Page<StipendEntity> getstipendinfo(String major, String stu_class, String time, String level, Pageable pageable);
}
